package com.sap.jcp.sm.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;
import com.sap.jcp.sm.domain.Config;

public class ConfigDAOImpl implements ConfigDAO{
	@SessionTarget
	Session session;
	@TransactionTarget
	Transaction transaction;
	@Override
	public void createOrUpdate(Config config) {
		session.saveOrUpdate(config);
	}
	@Override
	public Config list() {
		List<Config> config = session.createQuery("from Config").list();
		if (config != null && config.size() > 0) {
			return config.get(0);
		}
		return new Config();
	}

	
}
